drop table wpg_document;
create table wpg_document
(
 NAME                                     VARCHAR2(64),
 MIME_TYPE                                VARCHAR2(48),
 DOC_SIZE                                 NUMBER,
 DAD_CHARSET                              VARCHAR2(128),
 LAST_UPDATED                             DATE,
 CONTENT_TYPE                             VARCHAR2(128),
 CONTENT                                  long raw,
 BLOB_CONTENT                             BLOB,
 constraint wpg_document_pk primary key( name )
)
/
--
drop table wpg_documentpart;
create table wpg_documentpart
(
 DOCUMENT                                 VARCHAR2(64),
 PART                                     VARCHAR2(64),
 UPLOADED                                 CHAR(1),
 constraint wpg_documentpart_pk primary key( document, part )
)
/
grant select, insert, update, delete on wpg_document to public;
grant select, insert, update, delete on wpg_documentpart to public;

drop public synonym wpg_document;
drop public synonym wpg_documentpart;
create public synonym wpg_document for wpg_document;
create public synonym wpg_documentpart for wpg_documentpart;

-- create these tables at the user's space to avoid security 
-- concern with session data
drop table JSERVER_SESSION_OBJECTS;
drop table JSERVER_SESSION_STORE;

create table JSERVER_SESSION_STORE
  (
   ID VARCHAR2(255),
   CreationTime DATE,
   MaxInactiveInterval NUMBER,
   LastAccessedTime    DATE,
   CONSTRAINT JSERVER_SESSION_STORE_PK PRIMARY KEY (ID)
  )
/

create table JSERVER_SESSION_OBJECTS
  (
   IdStore VARCHAR2(255),
   AttrName VARCHAR2(255),
   AttrValue XMLType,
   CONSTRAINT JSERVER_SESSION_OBJECT_PK PRIMARY KEY (IdStore,AttrName),
   CONSTRAINT JSERVER_SESSION_OBJECT_FK FOREIGN KEY (IdStore)
     REFERENCES JSERVER_SESSION_STORE(ID)
  )
/
grant select, insert, update, delete on JSERVER_SESSION_STORE to public;
grant select, insert, update, delete on JSERVER_SESSION_OBJECTS to public;
drop public synonym JSERVER_SESSION_STORE;
drop public synonym JSERVER_SESSION_OBJECTS;
create public synonym JSERVER_SESSION_STORE for JSERVER_SESSION_STORE;
create public synonym JSERVER_SESSION_OBJECTS for JSERVER_SESSION_OBJECTS;

commit;
exit
